<layout name='Layout/layout_main' />

<script type="text/javascript">
	function add() {
		$("#form_data input").each(function() {
			$(this).val("");
		});
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#opmode").val("add");
	}

	function btn_search() {
		sendForm("form_search", "__SELF__");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__");
			return false;
		}
	}

	function save() {
		if (check_form("form_data")) {
			sendForm("form_data", "{:U('save')}", "__URL__");
		}
	}

	function showdata(result) {
		for (var s in result.data) {
			set_val(s, result.data[s]);
		}
		$("#opmode").val("edit");
	}


	$(document).ready(function() {
		$(".sub_left_menu tbody tr").click(function() {
			$(".sub_left_menu  tr.active").removeClass("active");
			$(this).attr("class", "active");
			sendAjax("{:U('read')}", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})
	}); 
</script>
<form method="post" action="" id="form_search" name="form_search">
	<div class="title panel panel-default">
		<div class="panel-body">
			<h3 class="col-md-8">部门级别</h3>
			<div class="col-md-4 pull-right">
				<div class="search_box">
					<div class="input-group ">
						<input  class="form-control" type="text"  onkeydown="key_search();" name="keyword" id="keyword"/>
						<div class="input-group-btn">
							<a class="btn btn-default" onclick="btn_search();" > <i class="icon-search" ></i> </a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="pull-right">
			<a onclick="add()" class="btn btn-default">新增</a>
			<a onclick="save()"  class="btn btn-default">保存</a>
		</div>
	</div>
</div>
</form>
<!-- 功能操作区域结束 -->
<!-- 列表显示区域  -->
<div class="row">
	<div class="col-md-4 sub_left_menu ">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>编号</th>
					<th>名称</th>
					<th>状态</th>
				</tr>
			</thead>
			<tbody>
				<volist name="list" id="data">
					<tr id="{$data.id}">
						<td>{$data.grade_no}</td>
						<td>{$data.name}</td>
						<td>{$data.is_del|status}</td>
					</tr>			
			</volist>
			</tbody>
		</table>
	</div>
	<div class="col-md-8 last sub_content">
		<form id="form_data" name="form_data"method="post" class="well form-horizontal">
			<input type="hidden" name="id" id="id">
			<input type="hidden" name="ajax" id="ajax" value="0">
			<input type="hidden" name="opmode" id="opmode" value="">
		<div class="form-group col-md-12">
			<label class="col-md-4 control-label" for="grade_no">编码*：</label>
			<div class="col-md-8">
				<input class="form-control" type="text" id="grade_no" name="grade_no" check="require" msg="请输入编号">
			</div>
		</div>
					
		<div class="form-group col-md-12">
			<label class="col-md-4 control-label" for="name">名称*：</label>
			<div class="col-md-8">
				<input class="form-control"  type="text" id="name" name="name" check="require" msg="请输入名称">
			</div>
		</div>

		<div class="form-group col-md-12">
			<label class="col-md-4 control-label" for="sort">排序：</label>
			<div class="col-md-8">
				<input class="form-control"  type="text" id="sort" name="sort" >
			</div>
		</div>

		<div class="form-group col-md-12">
			<label class="col-md-4 control-label" for="is_del">状态：</label>
			<div class="col-md-8">
				<select  class="form-control" name="is_del" id="is_del">
					<option  value="0">启用</option>
					<option value="1">禁用</option>
				</select>
			</div>
		</div>
	</form>
</div>
